package com.alibaba.csp.sentinel.dashboard.util;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.List;

public class JSONUtils {
    public static <T> String toJSONString(Object object) {
        return JSON.toJSONString(object);
    }

    public static JavaType getCollectionType(Class<?> collectionClass, Class<?>... elementClasses) {
        return new ObjectMapper()
            .getTypeFactory()
            .constructParametricType(collectionClass, elementClasses);
    }

    public static <T> List<T> parseObject(Class<T> clazz, String string) {
            return  JSON.parseArray(string,clazz);

    }
}
